<?php

namespace App\Repositories\Eloquent;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Contract\CellRepository;
use App\Models\Cell;
use App\Validators\CellValidator;

/**
 * Class CellRepositoryEloquent.
 *
 * @package namespace App\Repositories\Eloquent;
 */
class CellRepositoryEloquent extends BaseRepository implements CellRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Cell::class;
    }

    /**
     * @inheritDoc
     */
    public function copy(Cell $cell, int $projectId, int $columnId, int $rowId): Cell
    {
        $payload = $cell->only([
            'content'
        ]);
        $payload['project_id'] = $projectId;
        $payload['column_id'] = $columnId;
        $payload['row_id'] = $rowId;
        return $this->create($payload);
    }

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
    
}
